-
Notifications
You must be signed in to change notification settings - Fork 798
feat: implement Tabular SQL UDFs #18511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 16 files at r1, all commit messages.
Reviewable status: 4 of 16 files reviewed, 5 unresolved discussions (waiting on @sundy-li)
src/meta/app/src/principal/user_defined_function.rs
line 59 at r1 (raw file):
pub return_types: Vec<(String, DataType)>, pub sql: String, }
add doc comment to important struct, and its field. The code itself does not show what the 'String' is.
Code quote:
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct UDTF {
pub arg_types: Vec<(String, DataType)>,
pub return_types: Vec<(String, DataType)>,
pub sql: String,
}
src/meta/protos/proto/udf.proto
line 74 at r1 (raw file):
message UDTFArg { string name = 1; DataType type = 2;
avoid using rust keyword
src/meta/proto-conv/src/udf_from_to_protobuf_impl.rs
line 295 at r1 (raw file):
Incompatible::new("UDTF.arg_types.ty can not be None".to_string()) })?)?) .into();
Avoid put more than one action into one line.
Do each thing in a separate line.
Code quote:
let ty = (&TableDataType::from_pb(arg_ty.r#type.ok_or_else(|| {
Incompatible::new("UDTF.arg_types.ty can not be None".to_string())
})?)?)
.into();
src/meta/proto-conv/src/udf_from_to_protobuf_impl.rs
line 327 at r1 (raw file):
)) })? .to_pb()?;
too large expression
Code quote:
let arg_type = infer_schema_type(arg_type)
.map_err(|e| {
Incompatible::new(format!(
"Convert DataType to TableDataType failed: {}",
e.message()
))
})?
.to_pb()?;
src/meta/proto-conv/tests/it/v142_udtf.rs
line 49 at r1 (raw file):
definition: UDFDefinition::UDTF(UDTF { arg_types: vec![], return_types: vec![],
testing empty vector? it does not test anything at all
Code quote:
arg_types: vec![],
return_types: vec![],
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
close: #5731
This UDTF feature encapsulates SQL as a table function, allowing it to be used in a similar way to a View.
Tests
Type of change
This change is